
<?php
$sidebar = '<ul><li><a class=\"disabled\" href=\"#\" onclick=\"return false;\">HOOAJAD</a></li>';
for ($end = $max_date; $end >= $min_date; $end--) {
    $start = $end - 1;
    $sidebar .= '<li><a href=\"' . site_url("competitions/$start-$end") . '\">' . ("$start-$end") . '</a></li>';
}
$sidebar .= '<li class=\"divider\"></li><li><a class=\"disabled\" href=\"#\" onclick=\"return false;\">AASTAD</a></li>';
for ($year = $max_date; $year >= $min_date; $year--) {
    $sidebar .= '<li><a href=\"' . site_url("competitions/$year") . '\">' . ("$year") . '</a></li>';
}
$sidebar .= '</ul>';
$sidebar = str_replace("\n", '\n', $sidebar);
?>

<script>
   
    $(".page-header").html("<h1>Võistluste lehekülg</h1>");
    $(".sidebar").html("<?php echo $sidebar ?>");
    $(document).ready(function () {
    });

</script>

<table class="table table-hover">
    <thead>
        <tr>
            <th>#</th>
            <th>Nimi</th>
            <th>Linn</th>
            <th>Riik</th>
            <th>Ujula</th>
            <th>Algus</th>
            <th>Lõpp</th>
            <th>Bassein</th>
            <th>Tulemusi</th>
<?php
//        if ($this->session->userdata('logged_in') && $this->session->userdata('is_admin')) {
//            echo '<th>Lisa fail</th>';
//        }
?>
        </tr>
    </thead><tbody>
            <?php
            $i = 1;
            foreach ($competitions as /* @var $comp Competition */ $comp) {
                $id = $comp->getId();
                echo '<tr onclick="document.location = \'' . site_url("competitions/summary/$id") . '\'">';
                echo '<td>' . $i . '</td>';
                echo '<td><a href="' . site_url("competitions/summary/$id") . '">' . $comp->getName() . '</a></td>';
                echo '<td>' . $comp->getCity() . '</td>';
                echo '<td>' . $comp->getCountryName() . '</td>';
                echo '<td>' . $comp->getFacility() . '</td>';
                echo '<td>' . Utils::est_date($comp->getStartDate()) . '</td>';
                echo '<td>' . Utils::est_date($comp->getEndDate()) . '</td>';
                echo '<td>' . $comp->getPool() . ' m</td>';
                echo '<td>' . $comp->getCountResults() . '</td>';
//        if ($this->session->userdata('logged_in') && $this->session->userdata('is_admin')) {
//            echo '<td>';
//            echo form_open_multipart('files/upload_results');
//            echo form_upload('results');
//            echo form_hidden('competition_id', $id);
//            echo form_submit('upload_results', 'Saada');
//            echo form_close();
//            echo '</td>';
//        }
                echo '</tr>';
                $i++;
            }
            ?>
    </tbody></table>